using System;
using System.Collections.Generic;
using Mindscape.BackgroundMotion.Model;

namespace Mindscape.BackgroundMotion.Website.Infrastructure
{
  /// <summary>
  /// Represents a search result in the Background Motion web site
  /// </summary>
  public class SearchResult : ISearchResult 
  {
    private IList<Contribution> _contributions;
    private int _totalResults;
    private int _pageNumber;
    private int _pageSize;

    /// <summary>
    /// The collection of Contributions found by the search
    /// </summary>
    /// <value></value>
    public IList<Contribution> Contributions
    {
      get { return _contributions; }
      set { _contributions = value; }
    }

    /// <summary>
    /// The total number of results
    /// </summary>
    /// <value></value>
    public int TotalResults
    {
      get { return _totalResults; }
      set { _totalResults = value; }
    }

    /// <summary>
    /// The page number which this search result is spanning
    /// </summary>
    /// <value></value>
    public int PageNumber
    {
      get { return _pageNumber; }
      set { _pageNumber = value; }
    }

    /// <summary>
    /// The number of results per page
    /// </summary>
    /// <value></value>
    public int PageSize
    {
      get { return _pageSize; }
      set { _pageSize = value; }
    }

    /// <summary>
    /// The total number of pages which the search results span over
    /// </summary>
    /// <value></value>
    public int Pages
    {
      get
      {
        return (int)(Math.Ceiling((decimal)TotalResults / PageSize));
      }
    }
  }
}
